﻿using Orderr;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OrderForm
{
    public partial class Form2 : Form
    {
        public List<OrderDetails> details;
        public Form2()
        {
            InitializeComponent();
            detailsGrid.DataSource = details;
            details = new List<OrderDetails>();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Good good = new Good(textBox3.Text, Convert.ToInt32(textBox4.Text));
            OrderDetails detaill = new OrderDetails(good, Convert.ToInt32(textBox5.Text));
            details.Add(detaill);
            detailsGrid.DataSource = null;
            detailsGrid.DataSource = details;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Order order = new Order(Convert.ToInt32(textBox2.Text), new Client(textBox1.Text), details);
            Form1 form1 = (Form1)this.Owner;
            form1.master.add(order);
            form1.OrderGrid.DataSource = null;
            form1.OrderGrid.DataSource = form1.master.Orders;
            this.Close();
        }
    }
}
